package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/dao"
	"activity_srv/internal/svc"
	"context"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type BargainActivityLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBargainActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BargainActivityLogic {
	return &BargainActivityLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 砍价活动
func (l *BargainActivityLogic) BargainActivity(in *activity.BargainActivityAddRequest) (*activity.BargainActivityAddResponse, error) {
	code, err := dao.BargainAdd(int(in.BargainId), int(in.UserId))
	if err != nil {
		pkg.Error("参加失败")
		return nil, err
	}
	return &activity.BargainActivityAddResponse{
		Message: "成功",
		Code:    code,
	}, nil
}
